#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <map> 
using namespace std; 

map<string,int> mapTele; 
char mapNum[26] = {'2','2','2','3','3','3','4','4','4',
	'5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'};
char* translate(char *s){
	char *temp = (char*)malloc(9); 
	bzero(temp,9);
	int i = 0; 
	while(*s){
		if( 65 <= s[0] && s[0]<= 90){
			switch(s[0]){
				case 'Q':
					break; 
				case 'Z':
					break; 
				case '-':
					break; 
				default:
					cout << s[0] << endl; 
					cout << mapNum[int(*s)-65];
					temp[i++] = mapNum[int(*s)-65]; 
			}	
		}
		if( 48 <= s[0] && s[0] <= 57) 
		{
			temp[i++] = s[0];
		}
		if(i == 3){
			temp[i++] = '-';
		}
		s++;
	}
	return temp ;
}
void updateMap(char* s){
	string temp(s); 
	if(mapTele.find(temp) != mapTele.end()){
		mapTele[temp] ++; 
	}
	else{
		mapTele[temp] = 1; 
	}
}
int main(){
	int n; 
	cout << "请您输入所拥有的行数： " ; 
	cin >> n ; 
	char buf[20]= {0} ; 
	while(n--){
		cin >> buf ; 
		char* s = translate(buf); 
		cout << s << endl;
		updateMap(s); 
		bzero(buf,20);
	}
	map<string,int> :: iterator it = mapTele.begin(); 
	while(it != mapTele.end()){
		cout << (*it).first.c_str() << ":" << (*it).second << endl;
		it++;
	}
}
